home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <intuition/intuition.h>
- #include <graphics/text.h>
- #include <libraries/dos.h>
- #include <EasySound.h>
-
- #define LEFT 1
- #define RIGHT 2
- #define UP 3
- #define DOWN 4
-
- #define FLOOR 2
- #define BONUS 3
- #define GREYWALL 1
- #define PINKWALL 0
- #define PINKWALL2 4
- #define CLOSEDDOOR 5
- #define OPENEDDOOR 6
- #define KEY 7
- #define HOLE 8
- #define P1BONUS 9
- #define P2BONUS 10
-
- #define FIRE 1
- #define RIGHT 2
- #define LEFT 4
- #define DOWN 8
- #define UP 16
-
- #define PORT1 1
- #define PORT2 2
-
- struct TextAttr Font1DEF =
- {
- "topaz.font",
- 8,
- FS_NORMAL,
- FPF_ROMFONT
- };
-
- struct TextAttr Font2DEF =
- {
- "AM.font",
- 18,
- FS_NORMAL,
- FPF_DISKFONT
- };
-
- struct NewScreen PanelScreenDEF =
- {
- 0, 195, 320, 56,
- 4,
- 0, 1,
- SPRITES,
- CUSTOMSCREEN,
- &Font1DEF,
- NULL,
- NULL,
- NULL
- };
-
- struct NewWindow PanelWindowDEF =
- {
- 0, 0, 320, 56,
- 0, 1,
- VANILLAKEY,
- BORDERLESS | SIMPLE_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0, 0, 0, 0,
- CUSTOMSCREEN
- };
-
- USHORT PanelColors[16];
-
- struct NewScreen GameScreenDEF =
- {
- 0, 0, 320, 256,
- 4,
- 0, 1,
- SPRITES,
- CUSTOMSCREEN,
- &Font2DEF,
- NULL,
- NULL,
- NULL
- };
-
- struct NewWindow GameWindowDEF =
- {
- 0, 0, 320, 200,
- 0, 1,
- VANILLAKEY,
- BORDERLESS | SIMPLE_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0, 0, 0, 0,
- CUSTOMSCREEN
- };
-
- USHORT StdColors[16];
- USHORT GameColors[16];
-
- __chip USHORT mousedata[] =
- {
- 0, 0, 0, 0
- };
-
- struct Screen *gscreen = NULL;
- struct Screen *pscreen = NULL;
- struct Window *gwindow = NULL;
- struct Window *pwindow = NULL;
- struct RastPort *grp;
- struct RastPort *prp;
- struct ViewPort *gvp;
- struct ViewPort *pvp;
- UBYTE *gplane[4];
- UBYTE *pplane[4];
- APTR font2 = NULL;
- CPTR MoveSound = NULL;
- CPTR ShuffleSound = NULL;
- CPTR NoShuffleSound = NULL;
- CPTR BonusSound = NULL;
- CPTR FallSound = NULL;
- CPTR DoorSound = NULL;
- CPTR End1Sound = NULL;
- CPTR End2Sound = NULL;
-
- BOOL music = FALSE;
- BOOL sound;
- CPTR song = NULL;
-
- char Buffer[20];
-
- /****************************/
- /* GAME DATA */
- /****************************/
-
- UBYTE Area[12][20];
-
- SHORT Level = 1;
- SHORT Bonus = 0;
-
- SHORT PlayerCount = 2;
-
- struct Player
- {
- SHORT XPos, YPos;
- SHORT Score, Keys;
- SHORT Count, Collect;
- SHORT GamesWon, GamesPlayed;
-
- char *Name;
- };
-
- struct Player Player[10] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, "Pink",
- 0, 0, 0, 0, 0, 0, 0, 0, "Romulus",
- 0, 0, 0, 0, 0, 0, 0, 0, "Larry P.",
- 0, 0, 0, 0, 0, 0, 0, 0, "Donald D.",
- 0, 0, 0, 0, 0, 0, 0, 0, "J.R.",
- 0, 0, 0, 0, 0, 0, 0, 0, "Jan P.",
- 0, 0, 0, 0, 0, 0, 0, 0, "Cruise",
- 0, 0, 0, 0, 0, 0, 0, 0, "Heinz",
- 0, 0, 0, 0, 0, 0, 0, 0, "Herbert",
- 0, 0, 0, 0, 0, 0, 0, 0, "Hugo"
- };
-
- struct Player *p1, *p2;
-
- /****************************/
- /* FUNCTION DECLARARTION */
- /****************************/
-
- SHORT Game();
- void Competition();
- void EditLevel();
- void LoadGraphics();
- void LoadPanel();
- void LoadLevel();
- void LoadSounds();
- void OpenAll();
- void CloseAll(__A0 char *);
- void DoPlayer(__A0 struct Player *, __A1 struct Player *);
-
- void PutArea(__D0 SHORT, __D1 SHORT);
- void PrintAt(__A0 struct RastPort *, __D0 SHORT, __D1 SHORT, __D2 SHORT, __D3 char *);
- void OPrintAt(__A0 struct RastPort *, __D0 SHORT, __D1 SHORT, __D2 SHORT, __D3 char *);
-
- LONG InitPlayer();
- void RemMPlayer();
- void PlayModule(__A0 CPTR);
- void PlayModule2(__A0 CPTR);
- void StopPlayer();
- CPTR LoadModule(__A0 char *);
- void UnLoadModule(__A0 CPTR);
-
- UBYTE Joystick();
-
- /****************************/
- /* MAIN */
- /****************************/
-
- int main()
- {
- BOOL bool = TRUE;
- BOOL redraw = TRUE;
- BOOL keyboard = FALSE;
- BOOL change;
- char Buffer[20];
- SHORT mode = 0, page = 0;
-
- OpenAll();
- LoadSounds();
- LoadPanel();
- LoadGraphics();
-
- if ( music )
- sound = FALSE;
- else
- sound = TRUE;
-
- while (bool)
- {
- if ( redraw )
- {
- redraw = FALSE;
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 0, 319, 191);
-
- StdColors[0] = 0x000;
- StdColors[1] = 0x000;
- StdColors[2] = 0x000;
- StdColors[3] = 0x000;
- LoadRGB4(gvp, StdColors, 16);
-
- OPrintAt(grp, 160, 20, 0, "Shuffle Run");
- OPrintAt(grp, 160, 40, 0, "Coding by PINK");
- OPrintAt(grp, 160, 60, 0, "© 1992 by Paradise Soft");
-
- sprintf(Buffer, "Page %u", page+1);
- OPrintAt(grp, 150, 90, 1, Buffer);
-
- switch ( page )
- {
- case 0 :
- sprintf(Buffer, "Level %u", Level);
- OPrintAt(grp, 150, 115, 1, Buffer);
- OPrintAt(grp, 150, 135, 1, "»S« tart game");
- OPrintAt(grp, 150, 155, 1, "»E« dit level");
- OPrintAt(grp, 150, 180, 1, "»Q« uit");
- break;
- case 1 :
- if ( music )
- OPrintAt(grp, 150, 115, 1, "»M« usic On");
- else
- OPrintAt(grp, 150, 115, 1, "»M« usic Off");
-
- if ( sound )
- OPrintAt(grp, 150, 135, 1, "»S« ound On");
- else
- OPrintAt(grp, 150, 135, 1, "»S« ound Off");
- break;
- case 2 :
- sprintf(Buffer, "%u Player", PlayerCount);
- OPrintAt(grp, 150, 115, 1, Buffer);
- sprintf(Buffer, "Startlevel %u", Level);
- OPrintAt(grp, 150, 135, 1, Buffer);
- OPrintAt(grp, 150, 155, 1, "Competition");
- break;
- }
-
- StdColors[1] = 0xFFF;
- StdColors[2] = 0xAAA;
- StdColors[3] = 0x777;
- StdColors[4] = 0x707;
- LoadRGB4(gvp, StdColors, 16);
-
- change = TRUE;
- }
-
- UBYTE joy = Joystick(PORT2);
-
- if ( joy & 24 )
- {
- change = TRUE;
-
- if ( joy & 8 )
- {
- mode++;
-
- switch ( page )
- {
- case 0 :
- if ( mode > 4 )
- mode = 0;
- break;
- case 1 :
- if ( mode > 2 )
- mode = 0;
- break;
- case 2 :
- if ( mode > 3 )
- mode = 0;
- break;
- }
- }
- else
- {
- if ( mode > 0 )
- mode--;
- else
- switch ( page )
- {
- case 0 :
- mode = 4;
- break;
- case 1 :
- mode = 2;
- break;
- case 2 :
- mode = 3;
- break;
- }
- }
- }
-
- if ( change )
- {
- change = FALSE;
-
- SetAPen(grp, 0);
- RectFill(grp, 160, 75, 319, 185);
-
- switch ( mode + page*10)
- {
- case 0 :
- case 10 :
- case 20 :
- OPrintAt(grp, 170, 90, -1, "<- ->");
- break;
-
- case 1 :
- OPrintAt(grp, 170, 115, -1, "<- ->");
- break;
- case 2 :
- OPrintAt(grp, 170, 135, -1, "<-");
- break;
- case 3 :
- if ( (Level > 300) && (Level < 400) )
- OPrintAt(grp, 170, 155, -1, "<-");
- else
- OPrintAt(grp, 170, 155, -1, "lock");
- break;
- case 4 :
- OPrintAt(grp, 170, 185, -1, "<-");
- break;
-
- case 11 :
- OPrintAt(grp, 170, 115, -1, "<-");
- break;
- case 12 :
- OPrintAt(grp, 170, 135, -1, "<-");
- break;
-
- case 21 :
- OPrintAt(grp, 170, 115, -1, "<- ->");
- break;
- case 22 :
- OPrintAt(grp, 170, 135, -1, "<- ->");
- break;
- case 23 :
- OPrintAt(grp, 170, 155, -1, "<-");
- break;
- }
- }
-
- switch ( mode + page*10 )
- {
- case 0 :
- case 10 :
- case 20 :
- /***************/
- /* select page */
- /***************/
-
- if ( joy & 2 )
- {
- page++;
- if ( page > 2 )
- page = 0;
-
- redraw = TRUE;
- }
- else if ( joy & 4 )
- {
- page--;
- if ( page < 0 )
- page = 2;
-
- redraw = TRUE;
- }
- break;
-
- case 1 :
- case 22 :
- /****************/
- /* select level */
- /****************/
-
- if ( joy & 2 )
- {
- SHORT i, d = 20;
-
- while ( (Joystick(PORT2) & 2) && (Level < 400) )
- {
- Level++;
- SetAPen(grp, 0);
- if ( page == 0 )
- {
- sprintf(Buffer, "Level %u", Level);
- RectFill(grp, 0, 100, 160, 120);
- OPrintAt(grp, 150, 115, 1, Buffer);
- }
- else
- {
- sprintf(Buffer, "Startlevel %u", Level);
- RectFill(grp, 0, 120, 160, 140);
- OPrintAt(grp, 150, 135, 1, Buffer);
- }
-
- for ( i = d ; i && (Joystick(PORT2) & 2); i-- )
- Delay(1);
-
- if ( d > 1 )
- d--;
- }
-
- keyboard = FALSE;
- }
-
- if ( joy & 4 )
- {
- SHORT i, d = 20;
-
- while ( (Joystick(PORT2) & 4) && (Level > 1) )
- {
- Level--;
- SetAPen(grp, 0);
- if ( page == 0 )
- {
- sprintf(Buffer, "Level %u", Level);
- RectFill(grp, 0, 100, 160, 120);
- OPrintAt(grp, 150, 115, 1, Buffer);
- }
- else
- {
- sprintf(Buffer, "Startlevel %u", Level);
- RectFill(grp, 0, 120, 160, 140);
- OPrintAt(grp, 150, 135, 1, Buffer);
- }
-
- for ( i = d ; i && (Joystick(PORT2) & 4); i-- )
- Delay(1);
-
- if ( d > 1 )
- d--;
- }
- }
- break;
-
- case 2 :
- /**************/
- /* start game */
- /**************/
-
- if ( joy & 1 )
- {
- if ( Level != 0 )
- {
- p1 = &Player[0];
- p2 = &Player[1];
- LoadLevel();
- Game();
- redraw = TRUE;
- }
- }
- break;
-
- case 3 :
- /**************/
- /* edit level */
- /**************/
-
- if ( joy & 1 )
- {
- if ( (Level > 300) && (Level < 400) )
- {
- LoadLevel();
- EditLevel();
- redraw = TRUE;
- }
- else
- DisplayBeep(NULL);
- }
- break;
-
- case 4 :
- /********/
- /* quit */
- /********/
-
- if ( joy & 1 )
- {
- bool = FALSE;
- }
- break;
-
- case 11 :
- /****************/
- /* switch music */
- /****************/
-
- if ( joy & 1 )
- {
- music = !music;
- if ( !song )
- music = FALSE;
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 100, 160, 120);
-
- if ( music )
- {
- sound = FALSE;
- RectFill(grp, 0, 120, 160, 140);
- OPrintAt(grp, 150, 115, 1, "»M« usic On");
- OPrintAt(grp, 150, 135, 1, "»S« ound Off");
-
- PlayModule2(song);
- }
- else
- {
- OPrintAt(grp, 150, 115, 1, "»M« usic Off");
- StopPlayer();
- }
- }
- break;
-
- case 12 :
- /****************/
- /* switch sound */
- /****************/
-
- if ( joy & 1 )
- {
- sound = !sound;
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 120, 160, 140);
-
- if ( sound )
- {
- music = FALSE;
- StopPlayer();
-
- RectFill(grp, 0, 100, 160, 120);
- OPrintAt(grp, 150, 115, 1, "»M« usic Off");
- OPrintAt(grp, 150, 135, 1, "»S« ound On");
- }
- else
- {
- OPrintAt(grp, 150, 135, 1, "»S« ound Off");
- }
- }
- break;
-
- case 21 :
- /**********************/
- /* select playercount */
- /**********************/
-
- if ( joy & 2 )
- {
- SHORT i, d = 8;
-
- while ( (Joystick(PORT2) & 2) && (PlayerCount < 10) )
- {
- PlayerCount++;
- sprintf(Buffer, "%u Player", PlayerCount);
- SetAPen(grp, 0);
- WaitTOF();
- RectFill(grp, 0, 100, 155, 120);
- OPrintAt(grp, 150, 115, 1, Buffer);
-
- for ( i = d ; i && (Joystick(PORT2) & 2); i-- )
- Delay(1);
-
- if ( d > 1 )
- d--;
- }
- }
-
- if ( joy & 4 )
- {
- SHORT i, d = 8;
-
- while ( (Joystick(PORT2) & 4) && (PlayerCount > 2) )
- {
- PlayerCount--;
- sprintf(Buffer, "%u Player", PlayerCount);
- SetAPen(grp, 0);
- WaitTOF();
- RectFill(grp, 0, 100, 155, 120);
- OPrintAt(grp, 150, 115, 1, Buffer);
-
- for ( i = d ; i && (Joystick(PORT2) & 4); i-- )
- Delay(1);
-
- if ( d > 1 )
- d--;
- }
- }
- break;
-
- case 23 :
- /***************/
- /* competition */
- /***************/
-
- if ( joy & 1 )
- {
- if ( Level != 0 )
- {
- Competition();
- redraw = TRUE;
- }
- }
- break;
- }
-
- /* check keyboard */
- {
- struct IntuiMessage *msg;
- SHORT key;
-
- while ( msg = (struct IntuiMessage *)GetMsg(gwindow->UserPort) )
- {
- if ( msg->Class == VANILLAKEY )
- key = msg->Code;
-
- ReplyMsg(msg);
- }
-
- while ( msg = (struct IntuiMessage *)GetMsg(pwindow->UserPort) )
- {
- if ( msg->Class == VANILLAKEY )
- key = msg->Code;
-
- ReplyMsg(msg);
- }
-
- if ( (key >= '0') && (key <= '9') && (page != 1) )
- {
- if ( !keyboard )
- {
- Level = key - '0';
- keyboard = TRUE;
- }
- else
- {
- Level *= 10;
- Level += key - '0';
-
- if ( Level > 400 )
- Level = 400;
-
- if ( Level > 99 )
- keyboard = FALSE;
- }
-
- if ( (page == 0) && (mode == 3) )
- {
- SetAPen(grp, 0);
- RectFill(grp, 160, 75, 319, 185);
-
- if ( (Level > 300) && (Level < 400) )
- OPrintAt(grp, 170, 155, -1, "<-");
- else
- OPrintAt(grp, 170, 155, -1, "lock");
- }
-
- SetAPen(grp, 0);
- if ( page == 0 )
- {
- sprintf(Buffer, "Level %u", Level);
- RectFill(grp, 0, 100, 160, 120);
- OPrintAt(grp, 150, 115, 1, Buffer);
- }
- else
- {
- sprintf(Buffer, "Startlevel %u", Level);
- RectFill(grp, 0, 120, 160, 140);
- OPrintAt(grp, 150, 135, 1, Buffer);
- }
- }
- else if ( (key == 13) && (page == 0) )
- {
- keyboard = FALSE;
- }
- else if ( (key == 'm') && (page == 1) )
- {
- music = !music;
- if ( !song )
- music = FALSE;
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 100, 160, 120);
-
- if ( music )
- {
- sound = FALSE;
- RectFill(grp, 0, 120, 160, 140);
- OPrintAt(grp, 150, 115, 1, "»M« usic On");
- OPrintAt(grp, 150, 135, 1, "»S« ound Off");
-
- PlayModule2(song);
- }
- else
- {
- OPrintAt(grp, 150, 115, 1, "»M« usic Off");
- StopPlayer();
- }
- }
- else if ( (key == 's') && (page == 1) )
- {
- sound = !sound;
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 120, 160, 140);
-
- if ( sound )
- {
- music = FALSE;
- StopPlayer();
-
- RectFill(grp, 0, 100, 160, 120);
- OPrintAt(grp, 150, 115, 1, "»M« usic Off");
- OPrintAt(grp, 150, 135, 1, "»S« ound On");
- }
- else
- {
- OPrintAt(grp, 150, 135, 1, "»S« ound Off");
- }
- }
- else if ( (key == 's') && (page == 0) )
- {
- if ( Level != 0 )
- {
- p1 = &Player[0];
- p2 = &Player[1];
- LoadLevel();
- Game();
- redraw = TRUE;
- }
- }
- else if ( (key == 'e') && (page == 0) )
- {
- if ( (Level > 300) && (Level < 400) )
- {
- LoadLevel();
- EditLevel();
- redraw = TRUE;
- }
- else
- DisplayBeep(NULL);
- }
- else if ( (key == 'q') && (page == 0) )
- {
- bool = FALSE;
- }
- }
-
- while ( Joystick(PORT2) );
- }
-
- CloseAll("Goodbye...");
- }
-
- /****************************/
- /* Competition() */
- /****************************/
-
- void Competition()
- {
- SHORT list[10];
- BOOL bool = TRUE;
- SHORT i;
-
- /*****************/
- /* clear players */
- /*****************/
-
- for ( i = 0 ; i < 10 ; i++ )
- {
- Player[i].GamesWon = 0;
- Player[i].GamesPlayed = 0;
- }
-
- /************************/
- /* random first players */
- /************************/
-
- p1 = &Player[rand() % PlayerCount];
- do {
- p2 = &Player[rand() % PlayerCount];
- } while ( p2 == p1 );
-
- while ( bool )
- {
- BOOL loop = TRUE;
-
- Delay(5);
- while ( Joystick(PORT2) );
- Delay(5);
- while ( Joystick(PORT2) );
-
- /****************/
- /* print screen */
- /****************/
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 0, 319, 191);
-
- StdColors[0] = 0x000;
- StdColors[1] = 0x000;
- StdColors[2] = 0x000;
- StdColors[3] = 0x000;
- LoadRGB4(gvp, StdColors, 16);
-
- OPrintAt(grp, 160, 20, 0, "Shuffle Run Competition");
- sprintf(Buffer, "Next Level : %u", Level);
- OPrintAt(grp, 160, 60, 0, Buffer);
-
- OPrintAt(grp, 145, 90, 1, p1->Name);
- OPrintAt(grp, 160, 90, 0, "vs.");
- OPrintAt(grp, 175, 90, -1, p2->Name);
-
- sprintf(Buffer, "%u%% = %u/%u", (p1->GamesPlayed > 0) ? (100 * p1->GamesWon / p1->GamesPlayed ) : 0, p1->GamesWon, p1->GamesPlayed);
- OPrintAt(grp, 145, 120, 1, Buffer);
- sprintf(Buffer, "%u/%u = %u%%", p2->GamesWon, p2->GamesPlayed, (p2->GamesPlayed > 0) ? (100 * p2->GamesWon / p2->GamesPlayed) : 0);
- OPrintAt(grp, 175, 120, -1, Buffer);
-
- OPrintAt(grp, 150, 150, 1, "Continue");
- OPrintAt(grp, 160, 150, -1, "<-");
- OPrintAt(grp, 150, 180, 1, "Cancel");
-
- StdColors[1] = 0xFFF;
- StdColors[2] = 0xAAA;
- StdColors[3] = 0x777;
- StdColors[4] = 0x707;
- LoadRGB4(gvp, StdColors, 16);
-
- i = 0;
-
- /*****************/
- /* select option */
- /*****************/
-
- while ( loop )
- {
- UBYTE joy = Joystick(PORT2);
-
- /**************/
- /* move arrow */
- /**************/
-
- if ( joy & 24 )
- {
- SetAPen(grp, 0);
- RectFill(grp, 155, 135, 319, 185);
-
- if ( joy & 16 )
- {
- i = 0;
- OPrintAt(grp, 160, 150, -1, "<-");
- }
- else
- {
- i = 1;
- OPrintAt(grp, 160, 180, -1, "<-");
- }
- }
-
- if ( joy & 1 )
- {
- loop = FALSE;
-
- if ( i == 0 )
- {
- SHORT min = 1000;
-
- /**************/
- /* start game */
- /**************/
-
- while ( Joystick(PORT2) );
-
- LoadLevel();
-
- switch ( Game() )
- {
- case -1 :
- for ( i = 0 ; i < PlayerCount ; i++ )
- if ( (&Player[i] != p1) && (Player[i].GamesPlayed <= min) )
- {
- p2 = &Player[i];
- min = Player[i].GamesPlayed;
- }
- break;
-
- case 1 :
- for ( i = 0 ; i < PlayerCount ; i++ )
- if ( (&Player[i] != p2) && (Player[i].GamesPlayed <= min) )
- {
- p1 = &Player[i];
- min = Player[i].GamesPlayed;
- }
- break;
- }
-
- Level++;
- if ( Level > 400 )
- bool = FALSE;;
-
- }
- else
- bool = FALSE;
- }
-
- while ( Joystick(PORT2) );
- } /* while (loop) */
- } /* while (bool) */
-
- /* sort list */
-
- for ( i = 0 ; i < PlayerCount ; i++ )
- {
- list[i] = i;
- if ( Player[i].GamesPlayed == 0 )
- Player[i].GamesPlayed = 1;
- }
-
- for ( i = 0 ; i < PlayerCount ; i++ )
- {
- SHORT j;
- SHORT max = 100 * Player[list[i]].GamesWon / Player[list[i]].GamesPlayed;
- SHORT maxpos = i;
-
- for ( j = i + 1 ; j < PlayerCount ; j++ )
- {
- if ( 100 * Player[list[j]].GamesWon / Player[list[j]].GamesPlayed > max )
- {
- max = 100 * Player[list[j]].GamesWon / Player[list[j]].GamesPlayed;
- maxpos = j;
- }
- }
-
- if ( maxpos != i )
- {
- SHORT swap;
-
- swap = list[maxpos];
- list[maxpos] = list[i];
- list[i] = swap;
- }
- }
-
- SetAPen(grp, 0);
- RectFill(grp, 0, 0, 319, 191);
-
- StdColors[0] = 0x000;
- StdColors[1] = 0x000;
- StdColors[2] = 0x000;
- StdColors[3] = 0x000;
- LoadRGB4(gvp, StdColors, 16);
-
- OPrintAt(grp, 160, 20, 0, "Shuffle Run Competition");
- OPrintAt(grp, 160, 50, 0, "Ranking List");
-
- SHORT j = 1, k = -1;
-
- for ( i = 0 ; i < PlayerCount ; i++ )
- {
- SHORT l;
-
- sprintf(Buffer, "%u%%", l = 100 * Player[list[i]].GamesWon / Player[list[i]].GamesPlayed);
- OPrintAt(grp, (i/5)*160+150, (i%5)*25+80, 1, Buffer);
-
- if ( k == -1 )
- k = l;
- else if ( k != l )
- {
- k = j;
- j++;
- }
-
- sprintf(Buffer, "%u) %s", j, Player[list[i]].Name);
- OPrintAt(grp, (i/5)*160+5, (i%5)*25+80, -1, Buffer);
- }
-
- StdColors[1] = 0xFFF;
- StdColors[2] = 0xAAA;
- StdColors[3] = 0x777;
- StdColors[4] = 0x707;
- LoadRGB4(gvp, StdColors, 16);
-
- Delay(5);
- while ( Joystick(PORT2) );
- Delay(5);
- while ( Joystick(PORT2) );
- while ( !(Joystick(PORT2) & 1) );
- }
-
- /****************************/
- /* EditLevel() */
- /****************************/
-
- void Edit_Redraw(__D0 SHORT mode)
- {
- switch ( mode )
- {
- case FLOOR :
- ClipBlit(grp, 0, 224, grp, 304, 192, 16, 16, 0xC0);
- break;
- case GREYWALL :
- ClipBlit(grp, 16, 224, grp, 304, 192, 16, 16, 0xC0);
- break;
- case PINKWALL :
- ClipBlit(grp, 32, 224, grp, 304, 192, 16, 16, 0xC0);
- break;
- case PINKWALL2 :
- ClipBlit(grp, 48, 224, grp, 304, 192, 16, 16, 0xC0);
- break;
- case CLOSEDDOOR :
- ClipBlit(grp, 64, 224, grp, 304, 192, 16, 16, 0xC0);
- break;
- case HOLE :
- ClipBlit(grp, 0, 240, grp, 304, 192, 16, 16, 0xC0);
- break;
- case KEY :
- ClipBlit(grp, 16, 240, grp, 304, 192, 16, 16, 0xC0);
- break;
- case P1BONUS :
- ClipBlit(grp, 48, 240, grp, 304, 192, 16, 16, 0xC0);
- break;
- case P2BONUS :
- ClipBlit(grp, 32, 240, grp, 304, 192, 16, 16, 0xC0);
- break;
- case BONUS :
- ClipBlit(grp, 64, 240, grp, 304, 192, 16, 16, 0xC0);
- break;
- }
- ClipBlit(grp, 304, 192, grp, 304, 224, 16, 16, 0xC0);
- }
-
- void EditLevel()
- {
- p1 = &Player[0];
- p1->XPos = 0;
- p1->YPos = 0;
- p2 = &Player[1];
- p2->XPos = 19;
- p2->YPos = 11;
-
- /*************/
- /* draw area */
- /*************/
- {
- SHORT x, y;
-
- LoadRGB4(gvp, GameColors, 16);
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- PutArea(y, x);
- }
-
- ClipBlit(grp, 0, 192, grp, 128, 192, 16, 16, 0xC0); /* fill with floor */
- ClipBlit(grp, 0, 208, grp, 144, 192, 16, 16, 0xC0); /* with holes */
- ClipBlit(grp, 64, 208, grp, 160, 192, 16, 16, 0xC0); /* with bonus */
- ClipBlit(grp, 16, 192, grp, 128, 208, 16, 16, 0xC0); /* with graywall */
- ClipBlit(grp, 32, 192, grp, 144, 208, 16, 16, 0xC0); /* with pinkwall */
- ClipBlit(grp, 48, 192, grp, 160, 208, 16, 16, 0xC0); /* with pinkwall2 */
-
- SetAPen(grp, 0);
- RectFill(grp, 240, 192, 319, 207);
- SetAPen(grp, 5);
- PrintAt(grp, 200, 205, 0, "X");
- PrintAt(grp, 216, 205, 0, "Y");
- PrintAt(grp, 248, 205, 0, "Q");
- PrintAt(grp, 280, 205, 0, "S");
- ClipBlit(grp, 0, 192, grp, 0, 224, 320, 32, 0xC0);
-
- MoveScreen(pscreen, 0, 32);
-
- /************/
- /* mainloop */
- /************/
- {
- BOOL bool = TRUE;
- SHORT xpos = 0, ypos = 0;
- SHORT mode = FLOOR;
-
- Edit_Redraw(mode);
-
- while (bool)
- {
- SetAPen(grp, 5);
- Move(grp, 16*xpos, 16*ypos);
- Draw(grp, 16*xpos+15, 16*ypos);
- Draw(grp, 16*xpos+15, 16*ypos+15);
- Draw(grp, 16*xpos, 16*ypos+15);
- Draw(grp, 16*xpos, 16*ypos);
-
- Delay(5);
- UBYTE joy = Joystick(PORT2);
-
- if ( joy & 1 )
- {
- if ( ypos >= 12 )
- {
- switch ( xpos + (ypos - 12)*20)
- {
- case 5 :
- case 6 :
- case 26 :
- DisplayBeep(NULL);
- break;
-
- case 0 :
- mode = FLOOR;
- Edit_Redraw(mode);
- break;
- case 1 :
- mode = GREYWALL;
- Edit_Redraw(mode);
- break;
- case 2 :
- mode = PINKWALL;
- Edit_Redraw(mode);
- break;
- case 3 :
- mode = PINKWALL2;
- Edit_Redraw(mode);
- break;
- case 4 :
- mode = CLOSEDDOOR;
- Edit_Redraw(mode);
- break;
- case 20 :
- mode = HOLE;
- Edit_Redraw(mode);
- break;
- case 21 :
- mode = KEY;
- Edit_Redraw(mode);
- break;
- case 22 :
- mode = P2BONUS;
- Edit_Redraw(mode);
- break;
- case 23 :
- mode = P1BONUS;
- Edit_Redraw(mode);
- break;
- case 24 :
- mode = BONUS;
- Edit_Redraw(mode);
- break;
-
- case 8 :
- case 9 :
- case 10 :
- case 28 :
- case 29 :
- case 30 :
- {
- SHORT i;
-
- for ( i = 100 ; i ; i-- )
- {
- DisplayBeep(NULL);
- Delay(1);
-
- if ( Joystick(PORT2) == 0 )
- break;
- }
-
- if ( i )
- break;
-
- switch ( xpos + (ypos - 12)*20)
- {
- case 8 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = FLOOR;
- PutArea(y, x);
- }
- break;
- }
- case 9 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = HOLE;
- PutArea(y, x);
- }
- break;
- }
- case 10 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = BONUS;
- PutArea(y, x);
- }
- break;
- }
- case 28 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = GREYWALL;
- PutArea(y, x);
- }
- break;
- }
- case 29 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = PINKWALL;
- PutArea(y, x);
- }
- break;
- }
- case 30 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 20 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- Area[y][x] = PINKWALL2;
- PutArea(y, x);
- }
- break;
- }
- }
-
- break;
- }
- case 12 :
- {
- SHORT x, y;
-
- for ( x = 0 ; x < 10 ; x++ )
- for ( y = 0 ; y < 12 ; y++ )
- {
- switch ( Area[y][x] )
- {
- case P1BONUS :
- Area[11-y][19-x] = P2BONUS;
- break;
- case P2BONUS :
- Area[11-y][19-x] = P1BONUS;
- break;
- default :
- Area[11-y][19-x] = Area[y][x];
- break;
- }
-
- PutArea(11-y, 19-x);
- }
- break;
- }
- case 13 :
- {
- SHORT x, y;
-
- for ( y = 0 ; y < 6 ; y++ )
- for ( x = 0 ; x < 20 ; x++ )
- {
- switch ( Area[y][x] )
- {
- case P1BONUS :
- Area[11-y][19-x] = P2BONUS;
- break;
- case P2BONUS :
- Area[11-y][19-x] = P1BONUS;
- break;
- default :
- Area[11-y][19-x] = Area[y][x];
- break;
- }
-
- PutArea(11-y, 19-x);
- }
- break;
- }
- case 15 :
- bool = FALSE;
- break;
- case 17 :
- {
- Area[0][0] = 2;
- Area[11][19] = 2;
-
- struct FileHandle *file;
-
- if ( file = (struct FileHandle *)Open("Levels.data", MODE_OLDFILE) )
- {
- LONG index = (Level-1) * 240;
-
- Seek(file, index, OFFSET_BEGINNING);
-
- Write(file, Area, 240);
-
- Close(file);
- }
- else
- {
- DisplayBeep(NULL);
- }
- bool = FALSE;
- break;
- }
- }
- }
- else
- {
- if ( ((xpos == 0) && (ypos == 0)) || ((xpos == 19) && (ypos == 11)) )
- {
- DisplayBeep(NULL);
- }
- else
- {
- Area[ypos][xpos] = mode;
- PutArea(ypos, xpos);
- }
- }
- }
- else
- {
- if ( joy & 2 )
- {
- if ( ypos < 12 )
- PutArea(ypos, xpos);
- else
- ClipBlit(grp, 0, 224, grp, 0, 192, 320, 32, 0xC0);
-
- xpos++;
- if (xpos > 19)
- xpos = 0;
- }
- if ( joy & 4 )
- {
- if ( ypos < 12 )
- PutArea(ypos, xpos);
- else
- ClipBlit(grp, 0, 224, grp, 0, 192, 320, 32, 0xC0);
-
- xpos--;
- if (xpos < 0)
- xpos = 19;
- }
- if ( joy & 8 )
- {
- if ( ypos < 12 )
- PutArea(ypos, xpos);
- else
- ClipBlit(grp, 0, 224, grp, 0, 192, 320, 32, 0xC0);
-
- ypos++;
- if (ypos > 13)
- ypos = 0;
- }
- if ( joy & 16 )
- {
- if ( ypos < 12 )
- PutArea(ypos, xpos);
- else
- ClipBlit(grp, 0, 224, grp, 0, 192, 320, 32, 0xC0);
-
- ypos--;
- if (ypos < 0)
- ypos = 11;
- }
- }
- }
- }
-
- MoveScreen(pscreen, 0, -32);
- }
-
-
-